// Copyright 2008-2009 BUGCOLLECT.COM
// Author: Remus Rusanu
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//                 http://bugcollect.com/terms
//

package com.bugcollect;

import java.io.InputStream;

/**
 * The callback interface for report submission result notification.
 * Applications interested in knowing the result of a report submittion
 * and/or the response from bugcollect.com
 * should provide an object that impelements <code>IResponseCallback</code>
 * when invoking <code>ReportingManager.Submit</code>.
 */
public interface IResponseCallback {

    /**
     * Method invoked on succesful submittion.
     * A submittion is considered succesful if a response is received
     * from bugcollect.com. Application are expected to check the
     * <code>receivedResponse</code> to get the submittion status.
     * @see ReportingManager#Submit(com.bugcollect.Report, com.bugcollect.IResponseCallback, java.lang.Object)
     * @param submittedReport the <code>{@link Report}</code> submitted for which this callback applies
     * @param receivedResponse the <code>{@link Result}</code> response from bugcollect.com
     * @param state the state object supplied to the <code>{@link ReportingManager#Submit(com.bugcollect.Report, com.bugcollect.IResponseCallback, java.lang.Object)  Submit}</code> method.
     */
    public void responseReceived(
        Report submittedReport,
        Result receivedResponse,
        Object state);

    /**
     * Method invoked on failed submittion.
     * @param submittedReport  the <code>{@link Report}</code> submitted for which this callback applies.
     * @param submittionException the exception that occured during submittion.
     * @param state the state object supplied to the <code>{@link ReportingManager#Submit(com.bugcollect.Report, com.bugcollect.IResponseCallback, java.lang.Object)  Submit}</code> method.
     */
    public void submittionException(
        Report submittedReport,
        Throwable submittionException,
        InputStream errorStream,
        Object state);
}
